import router from './router'
router.beforeEach((to, from, next) => {
  console.log(to.query)
    if(to.query && to.query.token){
       // window.localStorage.setItem("token", to.query.token);
       next('/home')
    } else {
      if (to.path === '/login' || to.path === '/reg' || to.path === '/forgetPassword') {
         next()
      } else {
        axios.post(
          "baseapi/token/verifyToken?token="+ JSON.parse(window.localStorage.getItem('userInfo')).token
        ).then((res) => {
          if(res.data.code == 1){
            next()
          }else {
            next('/login')
          }
        }).catch((error) => {
          console.log(error)
        })

      }
    }
  })
